var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLoading: !0,
    currentTab: 0, 
    userbuystatus:0,
  },
  openvip(){
    var that = this;
    var userbuystatus =  that.data.userbuystatus;
    var currentTab = that.data.currentTab;
    console.log(userbuystatus);
    var openid = wx.getStorageSync('openid');
    if(openid == '')
    {
      wx.showModal({
        title: '提示',
        content:"请先登录",
        success:function(con)
        {
          if(con.confirm)
          {
            wx.navigateTo({
              url: '/hyb_yl/sgin/sgin',
            })
          }else{
            wx.switchTab({
              url: '/hyb_yl/tabBar/index/index',
            })
          }
        }
      })
    }else if(userbuystatus==0){
      wx.navigateTo({
        url: '/hyb_yl/backstageServices/pages/vippay/vippay?type=0&currentTab='+currentTab,
      })
    }else{
      wx.navigateTo({
        url: '/hyb_yl/backstageServices/pages/vippay/vippay?type=1&currentTab='+currentTab,
      })
    }
  },
  givevip(){
    var that = this;
    var openid = wx.getStorageSync('openid');
    if(openid == '')
    {
      wx.showModal({
        title: '提示',
        content:"请先登录",
        success:function(con)
        {
          if(con.confirm)
          {
            wx.navigateTo({
              url: '/hyb_yl/sgin/sgin',
            })
          }else{
            wx.switchTab({
              url: '/hyb_yl/tabBar/index/index',
            })
          }
        }
      })
    }else{
      wx.navigateTo({
        url: '/hyb_yl/backstageServices/pages/givevip/givevip',
      })
    }
    
  },
  buyrecord(){
    
    wx.navigateTo({
      url: '/hyb_yl/backstageServices/pages/vipbuyrecord/vipbuyrecord',
    })
  },
  topNavChange: function (e) {
    var that = this;
    var nextActiveIndex = e.currentTarget.dataset.current; //下标
    var quanyi_content = that.data.huiyuanlist[nextActiveIndex].quanyi_content;
    that.setData({
      currentTab: nextActiveIndex,
      nodes: quanyi_content,
    }); 
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    that.setData({
      bgc:bgc
    })
    app.util.request({
      'url': 'entry/wxapp/huiyuan.setting',
      data: {
        openid: wx.getStorageSync('openid'),
      },
      success: function (res) {
        that.setData({
          setting_goumai_thumb: res.data.setting_goumai_thumb,
          setting_title:res.data.setting_title,
          setting_content:res.data.setting_goumai_content,
          userbuystatus:res.data.userbuystatus,
          isLoading: !1
        })
      }
    })
    that.getAllhuiyuan();
  },
  getAllhuiyuan:function(){
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/huiyuan.allhuiyuan',
      data: {
        openid: wx.getStorageSync('openid'),
      },
      success: function (res) {
        if(that.data.currentTab=='0'){
          console.log(res.data[0])
          var quanyi_content = res.data[0].quanyi_content;
          that.setData({
            nodes: quanyi_content,
          })
        }
        that.setData({
          huiyuanlist: res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})